package com.diankangwo;

import com.diankangwo.config.HeadersCORSFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class DiangkangwomanagerApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(DiangkangwomanagerApplication.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(DiangkangwomanagerApplication.class);
	}


	@Bean
	public FilterRegistrationBean testFilterRegistration() {

		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(new HeadersCORSFilter());
		registration.addUrlPatterns("/*");
		registration.setName("HeadersCORSFilter");
		registration.setOrder(1);
		return registration;
	}
}
